package cn.hxth.cloud.provider.handler;

import cn.hxth.cloud.api.common.constant.ProcedureStatus;
import cn.hxth.cloud.api.domain.ProductionOrder;
import org.springframework.beans.factory.annotation.Autowired;


public abstract class ProductionHandlerManger {

    @Autowired
    protected MoldinngHandler moldinngHandler ;
    @Autowired
    protected PunchingHandler punchingHandler ;
    @Autowired
    protected HeatTreatmentHandler heatTreatmentHandler ;
    @Autowired
    protected   SurfacingHandler surfacingHandler ;
    @Autowired
    protected   StiflingHandler stiflingHandler ;
    @Autowired
    protected   CommittedHandler committedHandler ;

    public ProductionHandlerManger() {
        punchingHandler.setSuccessor(heatTreatmentHandler);
        heatTreatmentHandler.setSuccessor(surfacingHandler);
        surfacingHandler.setSuccessor(stiflingHandler);
        stiflingHandler.setSuccessor(committedHandler);

    }
    public ProductionHandler getProductionHandler(ProductionOrder productionOrder){
        if(productionOrder.getProcedureStatus()<= ProcedureStatus.MOLDING){
         return  moldinngHandler ;
        }
        else if(productionOrder.getProcedureStatus() == ProcedureStatus.PUNCHING){
            return  punchingHandler ;
        }
        else if(productionOrder.getProcedureStatus() == ProcedureStatus.HEAT_TREATMENT){
            return  heatTreatmentHandler ;
        }
        else if(productionOrder.getProcedureStatus() == ProcedureStatus.SURFACING){
            return  surfacingHandler ;
        }
       else  if(productionOrder.getProcedureStatus() == ProcedureStatus.STIFLING){
            return  stiflingHandler ;
        }
      else   {
            return  committedHandler ;
        }

    }
}
